package logic

import (
	"context"
	"mini/pkg"
	"mini/userrpc/userrpc"

	"mini/miniapi/internal/svc"
	"mini/miniapi/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ProjectRankLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewProjectRankLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ProjectRankLogic {
	return &ProjectRankLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ProjectRankLogic) ProjectRank(req *types.ProjectRankRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	rank, err := l.svcCtx.UserRpc.ProjectRank(l.ctx, &userrpc.ProjectRankRequest{})
	if err != nil {
		return &types.Response{
			Message: pkg.String(err.Error()),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "排行榜展示成功 ",
		Code:    200,
		Data:    rank,
	}, nil
}
